package com.zzx.schoolfellow.mapper;

import com.zzx.schoolfellow.model.entity.BmsPost;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface PostMapper {
    @Select("SELECT * FROM post")
    List<BmsPost> getAllPosts();

    @Select("SELECT * FROM post WHERE id=#{id}")
    BmsPost getPostById(Long id);

    @Insert("INSERT INTO post(userId,title,content,status) VALUES(#{userId},#{title},#{content},#{status})")
    void createPost(BmsPost post);

    @Update("UPDATE post SET title=#{title},content=#{content},status=#{status} WHERE id=#{id}")
    void updatePost(BmsPost post);

    @Delete("DELETE FROM post WHERE id=#{id}")
    void deletePost(Long id);

}
